<?php

require dirname(__FILE__) . "/../classes/imageClass.php";
require dirname(__FILE__) . "/../classes/albumClass.php";
require dirname(__FILE__) . "/../classes/connectionFactoryClass.php";
require dirname(__FILE__) . "/../classes/imageDao.php";
require dirname(__FILE__) . "/../classes/albumDao.php";



$image = new ImageClass();
$album = new AlbumClass();
$c = new ConnectionFactory();
$db = $c->getConnection();
$imageDao = new imageDao($db);
$albumDao = new albumDao($db);

$idAlbum = $_GET['album'];
$allPhotos = Array();
if (isset($_GET['album'])) {
    //procura pelo id do album
    $albumlist = $albumDao->getAlbuns($idAlbum);
    $allPhotos[0] = $imageDao->getAllPhotosByAlbum($idAlbum);
} else {
    //retorna todos os albuns
    $albumlist = $albumDao->getAlbuns('');

    if ($albumlist) {
        //cria uma array com fotos separadas por album 
        $i = 0;
        foreach ($albumlist as $l) {
            $allPhotos[$i] = $imageDao->getAllPhotosByAlbum($l->getIdAlbum());
            $i++;
        }
        
       
    }else {
        
        
        
        
    
        /*
function rrmdir($dir) { 
   if (is_dir($dir)) { 
     $objects = scandir($dir); 
     foreach ($objects as $object) { 
       if ($object != "." && $object != "..") { 
         if (filetype($dir."/".$object) == "dir") rrmdir($dir."/".$object); else unlink($dir."/".$object); 
       } 
     } 
     reset($objects); 
     rmdir($dir); 
   } */
 } 
}
?>
